package org.example;

import org.example.chrome.ChromeUtils;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.util.concurrent.TimeUnit;

public class Main3 {
    public static void main(String[] args) throws Exception {
        String aaa = "115.208.80.27:40043";
        ChromeOptions options = new ChromeOptions();
        // 设置代理
        Proxy proxy = new Proxy();
//        proxy.setHttpProxy(aaa);
        proxy.setSslProxy(aaa);

        options.setProxy(proxy);
        // 设备信息
        WebDriver DRIVER = new RemoteWebDriver(ChromeUtils.SERVICE.getUrl(), options);
        DRIVER.get("https://api.it120.cc/common/ip");
        TimeUnit.MINUTES.sleep(30);
    }

    public static String readClipboard() {
        String ret = "";
        Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
        // 获取剪切板中的内容
        Transferable clipTf = sysClip.getContents(null);

        if (clipTf != null) {
            // 检查内容是否是文本类型
            if (clipTf.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                try {
                    ret = (String) clipTf
                            .getTransferData(DataFlavor.stringFlavor);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return ret;
    }
}